package com.tanhua.autoFile;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;
import java.util.Date;

@Slf4j
@Configuration
//公共字段自动填充
public class MetaConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //获取当前线程中的副本变量

        metaObject.setValue("created",new Date());
        metaObject.setValue("updated",new Date());

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updated",new Date());

    }
}
